package req

import (
	"duanju-mq/pkg/json"
	"net/url"
)

type ReqArgs map[string]string

func ParsePostForm(kvs url.Values) ReqArgs {
	r := ReqArgs{}
	for k := range kvs {
		r[k] = kvs.Get(k)
	}
	return r
}

func (r ReqArgs) Get(key string) string {
	return r[key]
}

func (r ReqArgs) Del(key string) {
	delete(r, key)
}

func (r ReqArgs) Add(key, value string) {
	r[key] = value
}

func (r ReqArgs) String() string {
	j, _ := json.Marshal(r)
	return string(j)
}
